var groupAnagrams = function(strs) {
    let n = strs.length,
        ans = new Map();
    for(let i=0;i<n;i++){
        let num = strs[i].split('').map(c=>c.charCodeAt(0)).sort().join()
        if(ans.has(num)){
            //let count=[...ans.get(num),strs[i]]
            //ans.set(num,count)
            ans.get(num).push(strs[i]) //此事num索引所对的值是一个数组 引用类型  直接push
        }else{
            ans.set(num,[strs[i]])
        }
    }
    return Array.from(ans.values())
};

//console.log(groupAnagrams(["eat", "tea", "tan", "ate", "nat", "bat"]));